/*
    Copyright (C) 2012 Franco Riberi, FuDePAN

    This file is part of the Biopp Library.

    Biopp is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Biopp is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Biopp.  If not, see <http://www.gnu.org/licenses/>.

    This is a test file.
*/
#include <string>
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "biopp/biopp.h"

using namespace biopp;

TEST(RnaStructure, DefaultConstructor)
{
    SecStructure s;
    ASSERT_EQ(0, s.size());
}

TEST(RnaStructure, NonDefaultConstructor)
{
    SecStructure s(5);
    ASSERT_EQ(5, s.size());
}

TEST(RnaStructure, AllUnpaired)
{
    SecStructure s(6);
    for (SeqIndex i = 0; i < s.size(); i++)
    {
        ASSERT_TRUE(!s.is_paired(i));
    }
}

TEST(RnaStructure, OutOfRange)
{
    SecStructure s(6);
    ASSERT_THROW(s.is_paired(7), std::out_of_range);
}

TEST(RnaStructure, InvalidStructure)
{
    SecStructure s(7);
    ASSERT_THROW(s.pair(4, 6), InvalidStructureException);
}

TEST(RnaStructure, Paired)
{
    SecStructure s(6);
    SeqIndex a = 1;
    SeqIndex b = 5;
    s.pair(a, b);
    ASSERT_TRUE(s.is_paired(a));
    ASSERT_TRUE(s.is_paired(b));
}

TEST(RnaStructure, Unpaired)
{
    SecStructure s(9);
    SeqIndex a = 2;
    SeqIndex b = 7;
    s.pair(a, b);
    s.unpair(a);
    ASSERT_TRUE(!s.is_paired(a));
    ASSERT_TRUE(!s.is_paired(b));
}

